package com.changhong.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * @date:2019/10/16 11:23
 * @author:lilair
 */
@Controller
public class LoginController {
    @PostMapping("/user/login")
    public String login(@RequestParam("username") String name, @RequestParam("password") String pwd, HttpSession Session, Map<String, String> map){
        if (!StringUtils.isEmpty(name)&&"123456".equals(pwd)){
            Session.setAttribute("loginUser",name);
            return "redirect:/main.html";
        }
        map.put("msg","用户或密码输入错误");
        System.out.println("fail");
        return "login";
    }
}
